package acl.action;

import acl.hibernate.po.*;

import com.opensymphony.xwork2.ActionSupport;

public class RegAction extends ActionSupport{
	private OaUsers user;
	private String msg;
	private String state;
	public OaUsers getUser()
	{
		return this.user;
	}
	public void setUser(OaUsers user)
	{
		this.user=user;
	}
	public String getMsg()
	{
		return this.msg;
	}
	public void setMsg(String msg)
	{
		this.msg=msg;
	}
	public String getState()
	{
		return this.state;
	}
	public void setState(String state)
	{
		this.state=state;
	}
	/*
	 * 验证姓名的有效性，例如是否有重复名称
	 */
	public String validateUserName()
	{
		this.msg="";
		if(getUser()==null)
		{
			this.msg="username cannot be blank!";
			this.state="0";
			return SUCCESS;
		}
		if(getUser().getName().equals("xiongkai"))
		{
			this.msg="name 'xiongkai' has been existed,please choose another one!";
			this.state="0";
			return SUCCESS;
		}
		else
		{
			this.msg="ok!";
			this.state="1";
			return SUCCESS;
		}
	}
	/*
	 * (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception
	{
		this.msg="execute";
		return SUCCESS;
	}
}
